import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    user: JSON.parse(window.localStorage.getItem('user'))
  },
  mutations: {
    SETUSER (state, data) {
      state.user = data
      console.log(state.user)
      window.localStorage.setItem('user', JSON.stringify(state.user))
    },
    CLEARUSER (state) {
      window.localStorage.clear('user')
      state.user = null
    }
  },
  actions: {},
  modules: {}
})
